#include "tree.h"

bool start( char *in_fn, char *out_fn )
{
	CUTextFile in_file( in_fn, "r" );
	if( in_file.IsOpen() == false )	return false;

	CUTextFile out_file( out_fn, "w" );
	if( out_file.IsOpen() == false )	return false;

	int now_line=0;
	while(1)	{
		CUString line;
		if( in_file.ReadLine( line ) == false ) break;
		now_line++;

		CUStringList ls;
		ls.TokenizeByChar( line, " ", false );
		for( int i=0; i<ls.GetSize(); i++ )	{
			CUString tok = ls.GetAt(i);

			int idx = tok.ReverseFind('/');
			if( idx<0 )	{
				fprintf( stderr, "Invalid input file %d\n", now_line );
				return false;
			}


			if( i > 0 )	{
				fprintf( out_file.GetFP(), " " );
			}
			fprintf( out_file.GetFP(), "%s", tok.Left( idx ).GetStr() );
		}
		fprintf( out_file.GetFP(), "\n" );

	}



	return true;
}


int main( int argc, char *argv[] )
{
	if( argc != 3 )	{
		fprintf( stderr, "usage: strippos in-file out-file\n" );
		return 1;
	}

	if( start( argv[1], argv[2] ) == false )	{
		return 1;
	}

	return 0;
}


